package com.usian.cousemer.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.usian.cousemer.blockhandler.BlockHandler;
import com.usian.cousemer.blockhandler.GlobalFallback;
import com.usian.cousemer.feign.Userfeign;
import com.usian.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class OpenfeignController {
    @Autowired
    private Userfeign userfeign;
    @GetMapping("/open/getUser")
    public User getUser(Integer id){
        return userfeign.getUser(id);
    }


    @GetMapping("/open/getUser2")
    @SentinelResource(value = "getUserById2",
    blockHandlerClass = BlockHandler.class,
    blockHandler = "blockHandlerMethod",
    fallbackClass = GlobalFallback.class,
    fallback = "fallbackMethod")
    public User getUser2(Integer id,String nam){
        return userfeign.getUser(id,nam);
    }
}
